package it.uniroma2.art.owlart.model.syntax.manchester;

import it.uniroma2.art.owlart.models.OWLModel;
import it.uniroma2.art.owlart.exceptions.ModelUpdateException;
import it.uniroma2.art.owlart.model.ARTBNode;
import it.uniroma2.art.owlart.model.ARTNode;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;


public class IndividualList {
	private int numb;
	public List<Uri> list;
	public OWLModel model;
	public ARTBNode resource;

	public IndividualList(OWLModel mod) {
		numb=0;
		list=new LinkedList<Uri>();
		model=mod;
	}

	public int getElements() {
		return numb;
	}

	public void addElement(Uri toAdd) {
		list.add(toAdd);
		numb++;
	}

	public ARTBNode getResource() throws ModelUpdateException  {
		ListIterator<Uri> uriIterator=list.listIterator();
		ARTBNode b=model.createBNode();
		ArrayList<ARTNode> res=new ArrayList<ARTNode>();
		while(uriIterator.hasNext()) {
		    	//if(!model.existsResource(res, graphs))
			res.add(uriIterator.next().uriRes);
		}
		model.addOneOf(b.getID(), res);

		resource=b;
		return b;

	}
}
